<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Check for alphanumeric character(s)</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.ctype.html">Ctype 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ctype-alpha.html">ctype_alpha</a></div>
 <div class="up"><a href="ref.ctype.html">Ctype 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.ctype-alnum" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ctype_alnum</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">ctype_alnum</span> &mdash; <span class="dc-title">Check for alphanumeric character(s)</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ctype-alnum-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>ctype_alnum</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span>
   )</div>

  <p class="para rdfs-comment">
   Checks if all of the characters in the provided <span class="type"><a href="language.types.string.html" class="type string">string</a></span>,
   <em><code class="parameter">text</code></em>, are alphanumeric.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ctype-alnum-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">text</code></em></dt>

     <dd>

      <p class="para">
       The tested string.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ctype-alnum-returnvalues"> 
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> if every character in <em><code class="parameter">text</code></em> is either
   a letter or a digit, <strong><code>FALSE</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ctype-alnum-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4974">
    <p><strong>Example #1 A <span class="function"><strong>ctype_alnum()</strong></span> example (using the default locale)</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$strings&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'AbCd1zyZ9'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'foo!#$bar'</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$strings&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">ctype_alnum</span><span style="color: #007700">(</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;consists&nbsp;of&nbsp;all&nbsp;letters&nbsp;or&nbsp;digits.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;does&nbsp;not&nbsp;consist&nbsp;of&nbsp;all&nbsp;letters&nbsp;or&nbsp;digits.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The string AbCd1zyZ9 consists of all letters or digits.
The string foo!#$bar does not consist of all letters or digits.
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.ctype-alnum-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
如果给出一个 -128 到 255 之间(含)的整数, 将会被解释为该值对应的ASCII字符 (负值将加上 256 以支持扩展ASCII字符).
其它整数将会被解释为该值对应的十进制字符串.</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ctype-alnum-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ctype-alpha.html" class="function" rel="rdfs-seeAlso">ctype_alpha()</a> - Check for alphabetic character(s)</span></li>
    <li class="member"><span class="function"><a href="function.ctype-digit.html" class="function" rel="rdfs-seeAlso">ctype_digit()</a> - Check for numeric character(s)</span></li>
    <li class="member"><span class="function"><a href="function.setlocale.html" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale information</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.ctype.html">Ctype 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ctype-alpha.html">ctype_alpha</a></div>
 <div class="up"><a href="ref.ctype.html">Ctype 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
